home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / live / usr / include / db_185.h next >
Encoding:
C/C++ Source or Header  |  2001-04-26  |  5.7 KB  |  179 lines

  1. /*-
  2.  * See the file LICENSE for redistribution information.
  3.  *
  4.  * Copyright (c) 1996, 1997, 1998
  5.  *    Sleepycat Software.  All rights reserved.
  6.  */
  7. /*
  8.  * Copyright (c) 1990, 1993, 1994
  9.  *    The Regents of the University of California.  All rights reserved.
  10.  *
  11.  * Redistribution and use in source and binary forms, with or without
  12.  * modification, are permitted provided that the following conditions
  13.  * are met:
  14.  * 1. Redistributions of source code must retain the above copyright
  15.  *    notice, this list of conditions and the following disclaimer.
  16.  * 2. Redistributions in binary form must reproduce the above copyright
  17.  *    notice, this list of conditions and the following disclaimer in the
  18.  *    documentation and/or other materials provided with the distribution.
  19.  * 3. All advertising materials mentioning features or use of this software
  20.  *    must display the following acknowledgement:
  21.  *    This product includes software developed by the University of
  22.  *    California, Berkeley and its contributors.
  23.  * 4. Neither the name of the University nor the names of its contributors
  24.  *    may be used to endorse or promote products derived from this software
  25.  *    without specific prior written permission.
  26.  *
  27.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  28.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  31.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  33.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  34.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  35.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  36.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  37.  * SUCH DAMAGE.
  38.  *
  39.  *    @(#)db_185.h.src    8.7 (Sleepycat) 4/10/98
  40.  */
  41.  
  42. #ifndef _DB_185_H_
  43. #define    _DB_185_H_
  44.  
  45. #include <sys/types.h>
  46.  
  47. #include <limits.h>
  48.  
  49. /*
  50.  * XXX
  51.  * Handle function prototypes and the keyword "const".  This steps on name
  52.  * space that DB doesn't control, but all of the other solutions are worse.
  53.  */
  54. #undef    __P
  55. #if defined(__STDC__) || defined(__cplusplus)
  56. #define    __P(protos)    protos        /* ANSI C prototypes */
  57. #else
  58. #define    const
  59. #define    __P(protos)    ()        /* K&R C preprocessor */
  60. #endif
  61.  
  62. #define    RET_ERROR    -1        /* Return values. */
  63. #define    RET_SUCCESS     0
  64. #define    RET_SPECIAL     1
  65.  
  66. #ifndef    __BIT_TYPES_DEFINED__
  67. #define    __BIT_TYPES_DEFINED__
  68.  
  69.  
  70.  
  71.  
  72.  
  73. #endif
  74.  
  75. /*
  76.  * XXX
  77.  * SGI/IRIX already has a pgno_t.
  78.  */
  79. #ifdef    sgi
  80. #define    pgno_t    db_pgno_t
  81. #endif
  82.  
  83. #define    MAX_PAGE_NUMBER    0xffffffff    /* >= # of pages in a file */
  84. typedef u_int32_t    pgno_t;
  85. #define    MAX_PAGE_OFFSET    65535        /* >= # of bytes in a page */
  86. typedef u_int16_t    indx_t;
  87. #define    MAX_REC_NUMBER    0xffffffff    /* >= # of records in a tree */
  88. typedef u_int32_t    recno_t;
  89.  
  90. /* Key/data structure -- a Data-Base Thang. */
  91. typedef struct {
  92.     void    *data;            /* data */
  93.     size_t     size;            /* data length */
  94. } DBT;
  95.  
  96. /* Routine flags. */
  97. #define    R_CURSOR    1        /* del, put, seq */
  98. #define    __R_UNUSED    2        /* UNUSED */
  99. #define    R_FIRST        3        /* seq */
  100. #define    R_IAFTER    4        /* put (RECNO) */
  101. #define    R_IBEFORE    5        /* put (RECNO) */
  102. #define    R_LAST        6        /* seq (BTREE, RECNO) */
  103. #define    R_NEXT        7        /* seq */
  104. #define    R_NOOVERWRITE    8        /* put */
  105. #define    R_PREV        9        /* seq (BTREE, RECNO) */
  106. #define    R_SETCURSOR    10        /* put (RECNO) */
  107. #define    R_RECNOSYNC    11        /* sync (RECNO) */
  108.  
  109. typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
  110.  
  111. /* Access method description structure. */
  112. typedef struct __db {
  113.     DBTYPE type;            /* Underlying db type. */
  114.     int (*close)    __P((struct __db *));
  115.     int (*del)    __P((const struct __db *, const DBT *, u_int));
  116.     int (*get)    __P((const struct __db *, const DBT *, DBT *, u_int));
  117.     int (*put)    __P((const struct __db *, DBT *, const DBT *, u_int));
  118.     int (*seq)    __P((const struct __db *, DBT *, DBT *, u_int));
  119.     int (*sync)    __P((const struct __db *, u_int));
  120.     void *internal;            /* Access method private. */
  121.     int (*fd)    __P((const struct __db *));
  122. } DB;
  123.  
  124. #define    BTREEMAGIC    0x053162
  125. #define    BTREEVERSION    3
  126.  
  127. /* Structure used to pass parameters to the btree routines. */
  128. typedef struct {
  129. #define    R_DUP        0x01    /* duplicate keys */
  130.     u_int32_t flags;
  131.     u_int32_t cachesize;    /* bytes to cache */
  132.     u_int32_t maxkeypage;    /* maximum keys per page */
  133.     u_int32_t minkeypage;    /* minimum keys per page */
  134.     u_int32_t psize;    /* page size */
  135.     int    (*compare)    /* comparison function */
  136.         __P((const DBT *, const DBT *));
  137.     size_t    (*prefix)    /* prefix function */
  138.         __P((const DBT *, const DBT *));
  139.     int    lorder;        /* byte order */
  140. } BTREEINFO;
  141.  
  142. #define    HASHMAGIC    0x061561
  143. #define    HASHVERSION    2
  144.  
  145. /* Structure used to pass parameters to the hashing routines. */
  146. typedef struct {
  147.     u_int32_t bsize;    /* bucket size */
  148.     u_int32_t ffactor;    /* fill factor */
  149.     u_int32_t nelem;    /* number of elements */
  150.     u_int32_t cachesize;    /* bytes to cache */
  151.     u_int32_t        /* hash function */
  152.         (*hash) __P((const void *, size_t));
  153.     int    lorder;        /* byte order */
  154. } HASHINFO;
  155.  
  156. /* Structure used to pass parameters to the record routines. */
  157. typedef struct {
  158. #define    R_FIXEDLEN    0x01    /* fixed-length records */
  159. #define    R_NOKEY        0x02    /* key not required */
  160. #define    R_SNAPSHOT    0x04    /* snapshot the input */
  161.     u_int32_t flags;
  162.     u_int32_t cachesize;    /* bytes to cache */
  163.     u_int32_t psize;    /* page size */
  164.     int    lorder;        /* byte order */
  165.     size_t    reclen;        /* record length (fixed-length records) */
  166.     u_char    bval;        /* delimiting byte (variable-length records */
  167.     char    *bfname;    /* btree file name */
  168. } RECNOINFO;
  169.  
  170. #if defined(__cplusplus)
  171. extern "C" {
  172. #endif
  173. DB *dbopen __P((const char *, int, int, DBTYPE, const void *));
  174.  
  175. #if defined(__cplusplus)
  176. }
  177. #endif
  178. #endif /* !_DB_185_H_ */
  179.